﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using BlogsAPI.Abstract;
using Newtonsoft.Json.Linq;

namespace BlogsAPI.Images
{
    /// <summary>
    /// Популярный GIF хостинг
    /// </summary>
    /// <example>http://giphy.com/gifs/marilyn-monroe-7HBvYbNTiUJJC?tc=1</example>
    [SingleImager(Link = "http://giphy.com")]
    public class Giphy : ImageServer
    {
        public override string GetThumb(string sLink)
        {
            if (String.IsNullOrEmpty(sLink)) return "";
            if (!sLink.Contains("/gifs/")) return "";
            sLink = sLink.Split('?')[0];
            //http://i.giphy.com/7HBvYbNTiUJJC.gif
            return String.Format("http://i.giphy.com/{0}.gif", sLink.Split('/', '-').Last());
        }
    }
}
